<?php

function __autoload( $className ) {

	$classFile[] = PRE."lib/class/class.".$className.".php";
	$classFile[] = PRE."lib/interface/intrf.".$className.".php";
	$classFile[] = PRE."lib/config/conf.".$className.".php";
	$classFile[] = PRE."modules/".$className."/class.".$className.".php";
	
	$tab = array( 'controller', 'model', 'view' );
	$module = str_replace( $tab, "", strtolower( $className ) );

	$classFile[] = PRE."modules/".$module."/class.".$className.".php";

	$modules = dir( PRE."modules");

	while ( false !== ( $entry = $modules->read() ) ) {
		
		if ( is_dir( $modules->path."/".$entry ) && $entry != "." && $entry != ".." ) {
			
			$classFile[] = $modules->path."/".$entry."/class.".$className.".php";
		}
	}
	
	$modules->close();

	foreach ( $classFile as $val ) {

		if ( file_exists( $val ) ) {

			require_once( $val );
			return true;

		}

	}

}

?>